	     var http_request = false;
	     var PMUserName = '';
	     var Overlay = null;
	     var lastEvent = null;
	     var pmMsgWindow = null;
	     
	     var MAX_SET_DATA_ATTEMPT = 100;
	     var curDataSetAttempt = 0;

            function initPMRequest(username, receiverURL, doc, e) {

            
            
                lastEvent = e;
                Overlay = doc;
                PMUserName = username;
                var url = receiverURL;
                http_request = false;

                http_request = new XMLHttpRequest();
                if (http_request.overrideMimeType) {
                    http_request.overrideMimeType('text/html');
                }

                if (!http_request) {
                    alert('Giving up :( Cannot create an XMLHTTP instance');
                    return false;
                }
                
                if (pmMsgWindow!=null) {
                    pmMsgWindow.close();
                    pmMsgWindow =null;
                }      
                	     
                pmMsgWindow = window.open("chrome://swaksmack/content/message.html", "title", "chrome,centerscreen,width=300,height=300");    
                //pmMsgWindow = window.open("chrome://swaksmack/content/message.html", "title", "");
                        
                http_request.onreadystatechange = showPMInput;
                http_request.open('GET', url, true);
                http_request.send(null);

            }

            function showPMInput() {

                
                if (http_request.readyState == 4) {
                    if (http_request.status == 200) {
                                                   
                        var r_euid_node = getHTMLNodeByID(http_request.responseText, 'receiver_euid');
                        var euid_node = getHTMLNodeByID(http_request.responseText, 'euid');                                               
                        
                        var r_euid_val = getHTMLNodeValue(r_euid_node);
                        var euid_val = getHTMLNodeValue(euid_node);
                                                                                                                                  
                        curDataSetAttempt = 0;
                        
                        setPopupDivHTML(pmMsgWindow,PMUserName,'userName');     
                        setPopupInputValue(pmMsgWindow,euid_val,'euid');
                        setPopupInputValue(pmMsgWindow,r_euid_val,'receiver_euid');
                        
                        
                    } else {
                        alert('There was a problem initializing the PM.');
                    }
                }

            }
            
               //these methods need to have maximum try vars set so they do not run forever.
               function setPopupDivHTML (win, innerHTML, divid) {
                 var div;                                 
                 
                  
                 
                 div = win.document.getElementById(divid) ;                                  
                 if (div!=null) {
                   div.innerHTML = innerHTML;
                   
                 }
                 else {
                 if (curDataSetAttempt > MAX_SET_DATA_ATTEMPT) {                    
                    return; // just give up
                 }
                 curDataSetAttempt++;
                   setTimeout(function () {
                     setPopupDivHTML(win, innerHTML, divid);
                   }, 500);
                 }
               } 
               
               function setPopupInputValue (win, val, inputId) {
                 var input;   
                                  
                                             
                 input = win.document.getElementById(inputId) ;
                 if (input!=null) {
                   input.value = val;
                   
                 }
                 else {
                 if (curDataSetAttempt > MAX_SET_DATA_ATTEMPT) {
                    return; // just give up
                 }   
                 curDataSetAttempt++;
                   setTimeout(function () {                   
                     setPopupInputValue(win, val, inputId);
                   }, 500);
                 }
               } 
            
            function hidePop() {

                hideCurrentPopup();          
                
            }
            
            function getHTMLNodeByID(text, id)
            {
	            var regex = new RegExp('id="' + id + '"[^>]*>([^<]*)<');
	            var match = text.match(regex);
	            return match;
            	
            }
            
            function getHTMLNodeValue(strHTMLNode) {
	            var regex = new RegExp('value="(.*)"');
	            var match = String(strHTMLNode).match(regex);
	            return match[1];            
            }


		// end move




